package sc.test.spring.prop;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import sc.common.test.TestUtil;

@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
public class PropertiesTest1 {

    @Value("${owner}")
    public String ownerStr;

    //	@Value("${tester}")
    //	public String tester;

    @Value("${same}")
    public String same;

    public static final String DEF = "abcd";
    /**
     * 配置不存在时，使用默认配置
     */
    @Value("${djlkfajsdlkf:" + DEF + "}")
    public String defaultValue;

    @Autowired
    public AppConfig appConfig;

    @Test
    public void t1() {
        TestUtil.sp(ownerStr);

        TestUtil.sp(appConfig.tester);

        TestUtil.sp(same);

        TestUtil.sp(defaultValue);
    }
}
